summaryrefslogtreecommitdiff
path: root/app/[lng]/evcp/(evcp)/general-contracts/[id]/page.tsx
blob: 632f71457558189d2a1098bf4a73fcc32b4bdfce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { redirect, notFound } from 'next/navigation'
import { Shell } from "@/components/shell"
import { getContractById } from "@/lib/general-contracts/service"
import ContractDetailPage from "@/lib/general-contracts/detail/general-contract-detail"

interface PageProps {
  params: Promise<{ lng: string; id: string }>
}

export async function generateMetadata({ params }: PageProps) {
  const { id } = await params
  
  // ID 유효성 검사
  if (!id || isNaN(parseInt(id))) {
    return {
      title: "계약 상세",
      description: "일반계약 상세 정보",
    }
  }
  
  try {
    const contractId = parseInt(id)
    const contract = await getContractById(contractId)
    
    if (!contract) {
      return {
        title: "계약을 찾을 수 없습니다",
        description: "요청하신 계약을 찾을 수 없습니다.",
      }
    }

    return {
      title: `계약 상세 - ${contract.name}`,
      description: `계약번호: ${contract.contractNumber} (Rev.${contract.revision})`,
    }
  } catch {
    return {
      title: "계약 상세",
      description: "일반계약 상세 정보",
    }
  }
}

export default async function Page({ params }: PageProps) {
  const { lng, id } = await params
  
  // ID 유효성 검사
  const contractId = parseInt(id)
  if (isNaN(contractId) || contractId <= 0) {
    notFound()
  }

  try {
    // 계약 정보 사전 로드
    const contract = await getContractById(contractId)
    
    if (!contract) {
      notFound()
    }

    return (
      <Shell className="gap-4">
        <ContractDetailPage />
      </Shell>
    )
  } catch (error) {
    console.error("Error loading contract:", error)
    notFound()
  }
}